package com.youku.config;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

import org.apache.commons.lang3.StringUtils;
import org.springframework.util.Assert;

public class Action {
	private String path;

	private String[] keys;

	private String[] values;

	public Action(String path, String strKeys, String strValues) {
		this.path = path;
		this.keys = StringUtils.split(strKeys, ',');
		this.values = StringUtils.split(strValues, ',');
		Set<String> container = new HashSet<String>(Arrays.asList(values));
		Set<String> elements = new HashSet<String>(Arrays.asList(keys));
		Assert.isTrue(container.containsAll(elements), "key中含有未知属性");
	}

	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	public String[] getKeys() {
		return keys;
	}

	public void setKeys(String[] keys) {
		this.keys = keys;
	}

	public String[] getValues() {
		return values;
	}

	public void setValues(String[] values) {
		this.values = values;
	}

	@Override
	public String toString() {
		return "Action [path=" + path + ", keys=" + Arrays.toString(keys) + ", values=" + Arrays.toString(values) + "]";
	}

}
